package com.cs.study.homework._0229;

public class Demo {
    public static void main(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));

        String s3 = new String("hello");
        String s4 = "hello";
        System.out.println(s3 == s4);
        System.out.println(s3.equals(s4));

        String s5 = "hello";
        String s6 = "hello";
        System.out.println(s5 == s6);
        System.out.println(s5.equals(s6));

        System.out.println("--------------------------");

        String p1 = "Hello";
        String p2 = "Hello";
        String p3 = "Hel" + "lo";
        String p4 = "Hel" + new String("lo");
        String p5 = new String("Hello");
        String p7 = "H";
        String p8 = "ello";
        String p9 = p7 + p8;

        System.out.println(p1 == p2);// true
        System.out.println(p1 == p3);// ?
        System.out.println(p1 == p4);// false
        System.out.println(p1 == p9);// false
        System.out.println(p4 == p5);// false
    }
}
